package com.dfbz.dao;

import com.dfbz.dao.basedao.BaseDao;
import com.dfbz.model.Meeting;
import com.dfbz.model.User;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class MeetingDao extends BaseDao<Meeting> {

    private JdbcTemplate jdbcTemplate = getJdbcTemplate();

    public MeetingDao(Class<Meeting> meetingClass) {
        super(meetingClass);
    }

    public List<Meeting> getAllMeeting(String title,Integer startIndex,Integer pageSize){
        List<Meeting> query = jdbcTemplate.query("select * from meeting where title like ? limit ?,? ",
                          new BeanPropertyRowMapper<>(Meeting.class), "%" + title + "%", startIndex, pageSize);
        return query;
    }

    public Integer getAllMeetingNum(String title){
        String sql="select count(1) from meeting where title like ?";
        Integer integer = jdbcTemplate.queryForObject(sql, Integer.class,"%"+title+"%");
        return integer;
    }



}
